##h2
import numpy as np
import random


list1 = []
list2 = []
list3 = []
cnt = 0
N=99999
M=1000000
## N, M = map(int, input().split())
for i in range(N):
    #a, b = map(int, input().split())
    #k = int(a / b + 0.5)
    list1.append(random.randint(1,10000))
    list2.append(random.randint(1,10000))
    list3.append(random.randint(1,10000))
k = 0
while k < M:
    a = max(list1)
    index1 = list1.index(a)
    if list3[index1] <= 0:
        list1.pop(index1)
    else:
        cnt += a
        list1[index1] -= list2[index1]
        list3[index1] -= 1
        k += 1

print(cnt)



